Generating implicit variables for the forcing of I/Os Permalink

During the commissioning of a plant or machine it may be necessary to "force" the values applied at the inputs and outputs. If a device supports this you can cause special "force variables" to be generated for this purpose and use them, for example, in an HMI visualization.

Requirement: The device supports the functionality. You have a project in which an I/O map is configured for the device and which contains a program object ‎PLC_PRG‎.

  1. Open the device editor, “PLC Settings” tab, by double-clicking the device object in the device tree.

  2. Activate the option “Generate force variables for IO mapping”.

  3. Press [F11] to compile the application.

    Two variables are created for each I/O channel in accordance with the following syntax, in the process of which spaces in the channel name are replaced by underscores:

    ‎<device name>_<channel name>_<IECaddress>_force‎ of the type ‎BOOL‎ for activation and deactivation of forcing

    ‎<device name>_<channel name>_<IECaddress>_value‎ of the data type of the channel for defining the value that you want to force on the channel

    These variables are available in the Input Assistant in the category “Variables” / “IoConfig_Globals_Force_Variables.” You can use them in CODESYS in programming objects, in visualizations, in the symbol configuration, etc.

  4. Open the function block “PLC_PRG”, set the focus in the implementation part and press F2.

    The Input Assistant opens. The variables are available in the category “Variables” / “IoConfig_Globals_Force_Variables” as described above.

    A rising edge at the "Force variable" input activates the forcing of the respective input or output with the value given by the "Value variable". A falling edge deactivates the forcing. Deactivation by resetting the "Force" variable to ‎FALSE‎ is the requirement for being able to force a new value.

Take note of the following restrictions.

  • Forcing via the implicit force variables is only possible for channels that are mapped in the “I/O Mapping” of the device to an existing or recently created variable.

  • Forcing via the implicit force variables is not possible for unused inputs and outputs or those that are mapped to a variable via an AT declaration in an application program.

  • I/O channels that you want to force via the mechanism have to be used by CODESYS in at least one task.

  • CODESYS identifies forced inputs in the monitoring by the red Force symbol, but not forced input/outputs. The forced value is used only implicitly by the I/O driver for writing to the device.

For more information, see: ⮫ “Forcing and Writing of Variables ”